﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using StudyEnglish.Model;
using System.ComponentModel;

namespace StudyEnglish
{
    public partial class DailyList : PhoneApplicationPage
    {
        public DailyList()
        {
            InitializeComponent();
            LoadDay();
        }
      
        private void LoadDay()
        {
            int countLst;
            App.DayVM.GetMaxDaily(App.userID);
            countLst = App.DayVM.MaxDaily;
            List<string> lstDay = new List<string>();
            for (int i = 1; i <= countLst; i++)
            {
                lstDay.Add("Ngày " + i);
            }
            DatabaseInfoListBox.ItemsSource = lstDay;

        }

        private void DatabaseInfoListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (DatabaseInfoListBox.SelectedIndex == -1)
                return;
            NavigationService.Navigate(new Uri("/VolList.xaml?index=" + DatabaseInfoListBox.SelectedIndex, UriKind.Relative));

            // Reset selected index to -1 (no selection)
            DatabaseInfoListBox.SelectedIndex = -1;
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/VolAdd.xaml", UriKind.Relative));
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/VolSearch.xaml", UriKind.Relative));
        }

       
        //private void logout_Click(object sender, RoutedEventArgs e)
        //{
        //    NavigationService.Navigate(new Uri("/UserLogin.xaml", UriKind.Relative));
        //}

        private void btnLogout_Click(object sender, EventArgs e)
        {
            NavigationService.Navigate(new Uri("/UserLogin.xaml", UriKind.Relative));
        }


        protected override void OnBackKeyPress(CancelEventArgs e)
        {
            while (NavigationService.CanGoBack)
            {
                NavigationService.RemoveBackEntry();
            }
        }
    }
}